<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<%@ include file="/commons/dateTime.jsp" %>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>装修申办审批</title>
<script type="text/javascript" src="${ctx }/scripts/public3.js"></script>
<script type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript"  src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<script>
	function setDays(){ //求天数

		var beginDate =  $('beginDate').value;
		var endDate=$('endDate').value;

		endList = endDate.split("-")
		endDate = new Date(endList[1] + '-' + endList[2] + '-' + endList[0]) //转换为12-18-2002格式

		beginList = beginDate.split("-")
		beginDate = new Date(beginList[1] + '-' + beginList[2] + '-' + beginList[0])

		if (beginDate > endDate){
			$('renovateDays').value="";
			return ;
		}

		var iDays = parseInt(Math.abs(endDate - beginDate) / 1000 / 60 / 60 /24) //把相差的毫秒数转换为天数

		if (isNaN(iDays)){
			$('renovateDays').value="";
		}else{
			$('renovateDays').value=iDays;
		}


	}

	function setCSS(flag){ //设置备注样式
		if (flag == 1){	//通过
			$('td_remark').className = "aux_intable_td2";
			Validation.removeElmValidate('remark');
			$('remark').className = "max-length-100";
		}else{  //不通过
			$('td_remark').className = "aux_intable_require_more";
			$('remark').className = "required max-length-100";
		}
	}

	function submitWin(){
		var isTrue=$("renovateApprovalForm").fireEvent("onSubmit");

  		if(!isTrue) return ;

		setButtonStatus(false);

		var ckArray = document.getElementsByName("approvalItems");
		var itemStr="";
		for(var i = 0; i < ckArray.length; i++){
			var itemConfigId = ckArray[i].value;
			var state = "";
			if(ckArray[i].checked){
				state = '001';
			}else{
				state = '002';
			}
			itemStr +=itemConfigId+","+state+":" ;
		}

		var approvalLevel=$('approvalLevel').value;
		var keyword = $('keyword').value;

		var params = $("renovateApprovalForm").serialize();

		var url = "${ctx}/renovation_renovateRequisitionAction.do?method=addRenovateApproval&itemStr="+itemStr;
		sendAjaxRequest(url,params,function(response){
				setButtonStatus(true);
				ajaxSubmitException(response.responseText);
				findFrame('main').refleshRenReqFrame(); //刷新主页面列表
				windowClose();
			});
	}

	function setButtonStatus(status){ //设置按钮状态 true 代表可用 false代表不可用
		$("btn1_22").disabled = !status;
		$("btn1_32").disabled = !status;
	}

	function init(){
		setDays();
	}

</script>
</head>

<body onload="setDays();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg">
	    <table border="0" cellpadding="0" cellspacing="0">
	      <tr><td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle" /> <span class="window_head_intext">装修申办审批</span></td></tr>
	    </table>
    </td>
  </tr>
  <tr>
    <td valign="middle" class="content">
    <div  id="tab_subMenu4"  style="overflow:auto;height:280px;">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="container_in_show">
      <tr>
        <td >
			 <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
                      <tr>
                        <td><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
                          <tr>
                            <td colspan="4" class="aux_titletable">业主资料</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">房 号：</td>
                            <td class="aux_intable_td2">${requisitionVO.houseNumber }</td>
                            <td class="aux_intable_td1">装修联系人：</td>
                            <td class="aux_intable_td2">${requisitionVO.linkman }</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">业主姓名：</td>
                            <td class="aux_intable_td2">${requisitionVO.clientNames }</td>
                            <td class="aux_intable_td1">装修联系人电话：</td>
                            <td class="aux_intable_td2">${requisitionVO.linkManPhone }</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">装修建筑面积：</td>
                            <td colspan="3" class="aux_intable_td2">${requisitionVO.area }</td>
                          </tr>
                          <tr>
                            <td colspan="4" class="aux_titletable">装修公司承接装修</td>
                          </tr>
                          <tr>
                            <td valign="top" class="aux_intable_td1">装修承建商：</td>
                            <td class="aux_intable_td2">${requisitionVO.companyName }</td>
                            <td class="aux_intable_td1">防火负责人：</td>
                            <td class="aux_intable_td2">${requisitionVO.fireproofingMan }</td>
                          </tr>
                          <tr>
                            <td valign="top" class="aux_intable_td1">资质等级：</td>
                            <td class="aux_intable_td2">${requisitionVO.levelView }</td>
                            <td class="aux_intable_td1">装修申请日期：</td>
                            <td valign="top" class="aux_intable_td2">${requisitionVO.requisitionDate }</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">现场负责人姓名：</td>
                            <td class="aux_intable_td2">${requisitionVO.burdenMan }</td>
                            <td valign="top" class="aux_intable_td1">装修施工期限：</td>
                            <td class="aux_intable_td2">
	                            <input type="hidden" id="beginDate" value="<fmt:formatDate pattern='yyyy-MM-dd' value='${requisitionVO.beginDate}'/>">
				            	<input type="hidden" id="endDate" value="<fmt:formatDate pattern='yyyy-MM-dd' value='${requisitionVO.endDate}'/>">从&nbsp;
				            	<fmt:formatDate pattern='yyyy-MM-dd' value='${requisitionVO.beginDate}'/>&nbsp;到&nbsp;
				            	<fmt:formatDate pattern='yyyy-MM-dd' value='${requisitionVO.endDate}'/>&nbsp;&nbsp;
				            	<span id="renovateDays"></span>&nbsp;
				            </td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">现场负责人电话：</td>
                            <td class="aux_intable_td2">${requisitionVO.burdenManPhone }</td>
                            <td class="aux_intable_td1">记录人：</td>
                            <td valign="top" class="aux_intable_td2">${requisitionVO.creatorName }</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">身份证号码：</td>
                            <td class="aux_intable_td2">${requisitionVO.identityCard }</td>
                            <td class="aux_intable_td1">记录时间：</td>
                            <td valign="top" class="aux_intable_td2">
                              ${key.ammterUnit}<fmt:formatDate pattern="yyyy-MM-dd hh:mm:ss" value="${requisitionVO.createDate }" /></td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">装修项目：</td>
                            <td class="aux_intable_td2">${requisitionVO.items }</td>
                            <td valign="top" class="aux_intable_td1">备 注：</td>
                            <td valign="top" class="aux_intable_td2">${requisitionVO.remark }</td>
                          </tr>
                          <tr>
                            <td colspan="4" class="aux_titletable">装修审核</td>
                          </tr>
                        </table>
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab_line">
                            <tr>
                              <td valign="top">
								<ec:ceTable items="approvalList"
											autoIncludeParameters="true"
											var="item"
											action="${ctx}/renovation_renovateRequisitionAction.do?method=queryRequisitions"
											rowsDisplayed="${totalRows }"
											width="100%"
											view="pmsNoPageView"
											sortable="false"
											styleClass="gridData"
										>
									<ec:ceRow styleClass="grid" >
										<ec:ceColumn width="8%" property="approvalMan" headerCell="pmsHeadrCell"  title="审核人" />
										<ec:ceColumn width="45%"  property="approvalItemView" headerCell="pmsHeadrCell"  title="审核文件资料" />
										<ec:ceColumn width="8%"  property="result" headerCell="pmsHeadrCell"  title="审批结果">
											${item.result == '001' ? '通过' :'不通过'}
										</ec:ceColumn>
										<ec:ceColumn width="15%"  property="approvalTime" headerCell="pmsHeadrCell" title="审核时间"   cell="date" parse="yyyy-MM-dd" />
										<ec:ceColumn width="24%"  property="remark" headerCell="pmsHeadrCell" title="备 注"/>
									</ec:ceRow>
								</ec:ceTable>
                              </td>
                            </tr>
                          </table>
                          </td>
                      </tr>
              </table>

       	  </td>
      </tr>
    </table>
    </div>
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="container_in_show">
      <tr>
        <td valign="top">
		<div id="tab_subMenu3" >
			<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
				<tr>
				  <td>

<form   name="renovateApprovalForm" id="renovateApprovalForm" method="post" action=""  class="required-validate">
			<input id="keyword" name="keyword" value="${approvalVO.keyword }" type="hidden">
			<input id="requistionId" name="requistionId" value="${approvalVO.requistionId }" type="hidden">
			<input id="approvalLevel" name="approvalLevel" value="${approvalVO.approvalLevel }" type="hidden">
				  <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
				    <tr><td colspan="2" class="aux_titletable">装修审批：</td></tr>

				    <c:if test="${approvalVO.approvalLevel == '001' }">
					<tr>
						<td class="aux_intable_td1">审核文件资料：</td>
						<td class="aux_intable_td2" id="items_td" style="WORD-BREAK: break-all; WORD-WRAP: break-word">
							<c:forEach items="${itemList}" var="item">
								<input type="checkbox" name="approvalItems" id="${item.keyword}" value="${item.keyword}" />${item.itemName}&nbsp;&nbsp;&nbsp;&nbsp;</input>
							</c:forEach>
						</td>
				    </tr>
				    </c:if>

				   <c:if test="${approvalVO.approvalLevel == '002' }">
					   	<c:if test="${fn:length(itemList)>0}">
							<tr>
								<td class="aux_intable_td1">审核文件资料：</td>
								<td class="aux_intable_td2" id="items_td" style="WORD-BREAK: break-all; WORD-WRAP: break-word">
									<c:forEach items="${itemList}" var="item">
										<input type="checkbox" name="approvalItems" id="${item.keyword}" value="${item.keyword}" />${item.itemName}&nbsp;&nbsp;&nbsp;&nbsp;</input>
									</c:forEach>
								</td>
						    </tr>
					    </c:if>
				    </c:if>


				    <tr>
						<td valign="top" class="aux_intable_td1">审批结果：</td>
						<td class="aux_intable_require">
				 			<input type="radio" name="result" value="001" onClick="setCSS('1')" checked="checked" />通 过&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;
				       		<input type="radio" name="result" value="002" onClick="setCSS('2')" />不通过</td>
					</tr>
				    <tr>
				      	<td height="64" valign="top" class="aux_intable_td1">备 注：</td>
				      	<td id="td_remark" class="aux_intable_td2"><textarea name="remark" id="remark" cols="40" rows="3" class="max-length-200"></textarea></td>
				    </tr>
				  </table>
</form>
				  </td>
				</tr>
			</table>
		</div>
		</td>
	  </tr>
	</table>
	</td>
  </tr>
  <tr height="100px">
    <td class="window_footer"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0"  >
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onblur="btn_change(2)" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onClick="submitWin();"><img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" /> 保 存</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0" onClick="windowClose();">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onblur="btn_change(3)" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"><img src="${ctx}/images/ico_cancel.gif" border="0" align="absmiddle" /> 关 闭</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>